(deftemplate case
    (slot persoana)
    (slot animale)
    (slot tigari)
    (slot locatie))

(foreach ?p (create$  englez rus spaniol)
    (foreach ?a (create$ cal lup caine)
        (foreach ?t (create$ Kent LM LuckyStrike)
            (foreach ?l (create$ 1 2 3)
            (assert(case(persoana ?p)(animale ?a)(tigari ?t)(locatie ?l)))
            )
        )
    )
)

(facts)

(defrule rezolvare
?id1<-(case (persoana ?p1 & englez) (animale ?a1) (tigari ?t1) (locatie ?l1 & 1))
?id2<-(case (persoana ?p2 & ~?p1) (animale ?a2 & cal & ~?a1)(tigari ?t2 & ~?t1)(locatie ?l2 & ~?l1))
?id3<-(case (persoana ?p3 & ~?p1 & ~?p2) (animale ?a3 & ~?a1 & ~?a2) (tigari ?t3 & Kent & ~?t1 & ~?t2) (locatie ?l3 & ~?l2 & ~?l1))
       =>
(printout t " Englezul are un " ?a1 " si fumeaza " ?t1 " casa nr " ?l1 crlf)
(printout t " Rusul are un " ?a2 " si fumeaza " ?t2 " casa nr " ?l2 crlf)
(printout t " Spaniolul are un " ?a3 " si fumeaza " ?t3 " casa nr " ?l3 crlf crlf)
(retract ?id1)
(retract ?id2)
(retract ?id3)
    )

(run)


